
;	 FILE: ADVCODE1.ASM	    LAST MODIFIED: 10/19/84

;********************************************************************
;
;  VLOOK  - "LOOK" VERB HANDLER
;
;********************************************************************

VLOOK	 PROC
	 CALL  INDARK
	 LBEQ  REPLY
	 TEST  NOUNNO,0FFH
	 LBNE  LOOKOB
	 CALL  CLSTXT
VLOOK2:
	 CALL  DRAWSC
	 MOV   AH,ROOM
VLOOK_A:
	 LEA   BX,DESCTB	  ;FIND ROOM DESCRIPTION
VLOOK_B:
	 DEC   AH
	 JZ    VLOOK_D
VLOOK_C:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JNZ   VLOOK_C
	 JMP   SHORT VLOOK_B
VLOOK_D:
	 MOV   AL,[BX]
	 CMP   AL,0FFH
	 JNE   VLOOK_E
	 MOV   AH,[BX+1]
	 JMP   SHORT VLOOK_A
VLOOK_E:
	 CALL  DISPLY
	 MOV   AL,ROOM		  ;DISPLAY ALL ROOM DIRECTIONS
	 DEC   AL
	 MOV   CL,RMSIZE
	 MUL   CL
	 LEA   CX,ROOMTB
	 ADD   AX,CX
	 MOV   DI,AX
	 MOV   BX,AX		  ;SEE IF ANY EXITS EXIST
	 MOV   AH,RMSIZE
VLOOK_P:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JNZ   VLOOK_Q
	 DEC   AH
	 JNZ   VLOOK_P
	 JMP   SHORT VLOOK_R
VLOOK_Q:
	 LEA   BX,MSG1		;DIRECTION MSG
	 CALL  DISPLY
	 MOV   BX,OFFSET DIRECT
	 MOV   AH,RMSIZE
VLOOK_F:
	 INC   DI
	 MOV   AL,[DI-1]
	 CMP   AL,0
	 JLE   VLOOK_G
	 CALL  DISPLY
	 CALL  PUTCMA
VLOOK_G:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JNZ   VLOOK_G
	 DEC   AH
	 JNZ   VLOOK_F
	 CALL  PERIOD
VLOOK_R:
	 CALL  PNTRM1
	 MOV   DI,BX
	 MOV   AL,[BX]
	 CMP   AL,0
	 JE    VLOOK_O
	 LEA   BX,MSG2		;OBJECTS SEEN MSG
	 CALL  DISPLY
VLOOK_M:
	 MOV   AL,[DI]
	 INC   DI
	 CMP   AL,0
	 JE    VLOOK_N		  ;END OF OBJECTS
	 JL    VLOOK_M		  ;UNSEEN OBJECT
	 CALL  OBDESC
	 CALL  PUTCMA
	 JMP   SHORT VLOOK_M
VLOOK_N:
	 CALL  PERIOD
VLOOK_O:
	 JMP   REPLY
VLOOK	 ENDP

;********************************************************************
;
;  LOOKOB - GENERAL LOOK AT OBJECT ROUTINE
;
;********************************************************************

LOOKOB	 PROC
	 CALL  EQUOBJ
	 MOV   AL,NOUNNO
	 CMP   AL,6		  ;IS IT A DIRECTION?
	 JA    LOOKOB_A 	  ;  NO:CONTINUE ON
	 JMP   DMSG012		  ;  YES:DISPLAY "NUTHIN SPECIAL"
LOOKOB_A:
	 MOV   AH,0
	 CALL  HAVOBJ
	 JNZ   LOOKOB_B
	 MOV   AL,NOUNNO
	 CALL  CKOBJ
	 JZ    NOSEE
	 INC   AH
LOOKOB_B:
	 INC   AH
	 LEA   BX,OBJMSG
LOOKOB_C:
	 TEST  BYTE PTR [BX],0FFH
	 LBEQ  DMSG012
	 CMP   AL,[BX]
	 JE    LOOKOB_D
	 ADD   BX,3
	 JMP   SHORT LOOKOB_C
LOOKOB_D:
	 MOV   AL,AH
	 MOV   AH,0
	 ADD   BX,AX
	 MOV   AL,[BX]
	 CMP   AL,7
	 JE    NOSEE
	 CMP   AL,8
	 JE    ALRHAV
	 CMP   AL,10
	 JE    NOHAVE
	 JMP   DMSGXX
LOOKOB	 ENDP

;********************************************************************
;
;  NOSEE  - DISPLAY OBJECT NOT SEEN MESSAGE
;
;********************************************************************

NOSEE	 PROC
	 LEA   BX,MSG7
NOSEE1:
	 CALL  DISPLY
	 MOV   AL,NOUNNO
	 MOV   BX,OFFSET THEMTB
	 MOV   AH,0
NOSEE_A:
	 TEST  BYTE PTR [BX],0FFH
	 JZ    NOSEE_B
	 ADD   BX,2
	 CMP   AL,[BX-2]
	 JNE   NOSEE_A
	 MOV   AH,[BX-1]
NOSEE_B:
	 LEA   BX,LITTAB
NOSEE_C:
	 TEST  AH,0FFH
	 JZ    NOSEE_E
NOSEE_D:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JNZ   NOSEE_D
	 DEC   AH
	 JMP   SHORT NOSEE_C
NOSEE_E:
	 CALL DISPLY
	 JMP  REPLY
NOSEE	 ENDP

;********************************************************************
;
;  NOHAVE - DISPLAY DON'T HAVE OBJECT MESSAGE
;
;********************************************************************

NOHAVE	 PROC
	 LEA   BX,MSG10
	 JMP   SHORT NOSEE1
NOHAVE	 ENDP

;********************************************************************
;
;  ALRHAV - DISPLAY ALREADY HAVE OBJECT MESSAGE
;
;********************************************************************

ALRHAV	 PROC
	 LEA   BX,MSG8
	 JMP   SHORT NOSEE1
ALRHAV	 ENDP

;********************************************************************
;
;  OBDESC - DISPLAY THE DESCRIPTION FOR AN OBJECT
;
;  INPUT:  AL = OBJECT #
;
;********************************************************************

OBDESC	 PROC
	 PUSH  BX
	 PUSH  AX
OBDESC_A:
	 MOV   BX,OFFSET OBJTAB
OBDESC_B:
	 INC   BX
	 CMP   AL,[BX-1]
	 JE    OBDESC_D
OBDESC_C:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JNE   OBDESC_C
	 JMP   SHORT OBDESC_B
OBDESC_D:
	 MOV   AL,[BX]
	 CMP   AL,PNT
	 JNE   OBDESC_E
	 MOV   AL,[BX+1]
	 JMP   SHORT OBDESC_A
OBDESC_E:
	 CALL  DISPLY
	 POP   AX
	 POP   BX
	 RET
OBDESC	 ENDP

;********************************************************************
;
;  IFOUND - I FOUND AN OBJECT ROUTINE
;
;  INPUT:  AL = OBJECT #
;
;********************************************************************

IFOUND	 PROC
	 MOV   BX,OFFSET MSG11
	 CALL  DISPLY
	 CALL  OBDESC
	 MOV   AL,'!'
	 CALL  CHROUT
	 JMP   REPLY
IFOUND	 ENDP

;********************************************************************
;
;  VGO	  - "GO" VERB HANDLER
;
;********************************************************************

VGO	 PROC
	 JMP   SHORT VGO2
VNORTH:
	 MOV   AL,1
	 JMP   SHORT VGO1
VSOUTH:
	 MOV   AL,2
	 JMP   SHORT VGO1
VEAST:
	 MOV   AL,3
	 JMP   SHORT VGO1
VWEST:
	 MOV   AL,4
	 JMP   SHORT VGO1
VUP:
	 MOV   AL,5
	 JMP   SHORT VGO1
VDOWN:
	 MOV   AL,6
VGO1:
	 MOV   NOUNNO,AL
VGO2:
	 MOV   AL,NOUNNO
	 CMP   AL,0
	 JLE   VGO_C
VGO_D:
	 CMP   AL,6
	 JA    VGO_C
	 MOV   AL,ROOM
	 DEC   AL
	 MOV   CL,RMSIZE
	 MUL   CL
	 LEA   BX,ROOMTB
	 ADD   BX,AX
	 MOV   AL,NOUNNO
	 DEC   AL
	 MOV   AH,0
	 ADD   BX,AX
	 MOV   AL,[BX]
	 CMP   AL,0
	 JLE   VGO_B
EXITRM:
	 MOV   AH,AL
	 LEA   BX,EXITTB	  ;SPECIAL EXIT ROUTINES
VGO_E:
	 INC   BX
	 MOV   AL,[BX-1]
	 CMP   AL,0
	 JE    VGO_G
	 CMP   AL,ROOM
	 JE    VGO_F
	 ADD   BX,2
	 JMP   SHORT VGO_E
VGO_F:
	 CALL  WORD PTR [BX]
VGO_G:
	 INC   NEWRM
	 DISABLE
	 MOV   ROOM,AH
	 MOV   NOUNNO,0
VGO_A:
	 JMP   VLOOK
VGO_B:
	 LEA   BX,MSG3		;NO WAY TO GO MSG
	 CALL  DISPLY
	 JMP   REPLY
VGO_C:
	 JMP   BADINP
VGO	 ENDP

;********************************************************************
;
;  VINVE  - "INVENTORY" VERB HANDLER
;
;********************************************************************

VINVE	 PROC
	 LEA   BX,MSG5
	 CALL  DISPLY
	 LEA   BX,OBJECT
	 MOV   AL,0
	 MOV   AH,MAXOBJ1
VINVE_A:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JZ    VINVE_B
	 INC   AL
VINVE_B:
	 DEC   AH
	 JNZ   VINVE_A
	 TEST  AL,0FFH
	 JZ    VINVE_I
	 LEA   DI,OBJECT
	 MOV   AH,MAXOBJ1
VINVE_C:
	 INC   DI
	 MOV   AL,[DI-1]
	 CMP   AL,0
	 JE    VINVE_G
	 LEA   BX,OBJTAB
VINVE_D:
	 INC   BX
	 CMP   AL,[BX-1]
	 JE    VINVE_F
VINVE_E:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JNZ   VINVE_E
	 JMP   SHORT VINVE_D
VINVE_F:
	 MOV   AL,[BX]
	 CMP   AL,0FFH
	 JNE   VINVE_J
	 MOV   AL,[BX+1]
	 LEA   BX,OBJTAB
	 JMP   SHORT VINVE_D
VINVE_J:
	 MOV   AL,13
	 CALL  CHROUT
	 CALL  DISPLY
	 CALL  PUTCMA
VINVE_G:
	 DEC   AH
	 JNZ   VINVE_C
	 CALL  PERIOD
VINVE_H:
	 JMP   REPLY
VINVE_I:
	 LEA   BX,MSG6
	 CALL  DISPLY
	 JMP   SHORT VINVE_H
VINVE	 ENDP

;********************************************************************
;
;  VGET   - "GET" VERB HANDLER
;
;********************************************************************

VGET	 PROC
	 CALL  EQUOBJ
	 MOV   AL,NOUNNO
	 CMP   AL,0
	 LBEQ  BADINP
	 CMP   AL,128		  ;IS IT "GET ALL"?
	 JE    VGET_I		  ;  YES
	 CALL  LOCOBJ
	 JZ    VGET_M
	 CMP   AL,MXMVOB	  ;MOVABLE OBJECT?
	 JLE   VGET_A		  ;  YES
	 JMP   DMSG015		  ;  NO
VGET_A:
	 CALL  HAVOBJ
	 LBNE  ALRHAV
	 MOV   AL,OBJCNT
	 CMP   AL,MAXOBJ1
	 JAE   VGET_E
	 MOV   AL,NOUNNO
	 CALL  GETOBJ
	 JNZ   VGET01
VGET_M:
	 JMP   NOSEE
VGET_E:
	 JMP   DMSG009
VGET01:
	 CALL  GIVOBJ
	 CALL  CKDRAW
VGET_H:
	 JMP   REPLY
VGET_I:
	 CALL  PNTRM1		  ;PROCESS "GET ALL" COMMAND
VGET_J:
	 INC   BX
	 CMP   BYTE PTR [BX-1],0
	 JL    VGET_J
	 JE    VGET_H
	 MOV   AL,OBJCNT
	 CMP   AL,MAXOBJ1
	 JAE   VGET_E
	 MOV   AL,[BX-1]
	 CMP   AL,64
	 JA    VGET_J
	 CALL  CHKGA
	 JZ    VGET_J
	 CALL  GETOBJ
	 CALL  GIVOBJ
	 CALL  CKDRAW
	 JMP   SHORT VGET_I
VGET	 ENDP

;********************************************************************
;
;  VPUT   - "PUT" VERB HANDLER
;
;********************************************************************

VPUT	 PROC
	 CALL  EQUOBJ
	 MOV   AL,NOUNNO
	 CMP   AL,0
	 LBEQ  BADINP
	 CMP   AL,128		  ;IS IT "PUT ALL"?
	 JE    VPUT_E		  ;  YES
	 CALL  HAVOBJ
	 LBEQ  NOHAVE
	 CALL  PUTOBJ
	 CALL  CKDRAW
	 MOV   AH,0
	 CALL  REPOBJ
VPUT_D:
	 JMP   REPLY
VPUT_E:
	 LEA   BX,OBJECT	  ;PROCESS "PUT ALL" COMMAND
	 MOV   AH,MAXOBJ1
VPUT_F:
	 INC   BX
	 MOV   AL,[BX-1]
	 CMP   AL,0
	 JE    VPUT_G
	 CALL  CHKPA
	 JZ    VPUT_G
	 MOV   BYTE PTR [BX-1],0
	 DEC   OBJCNT
	 CALL  PUTOBJ
	 CALL  CKDRAW
VPUT_G:
	 DEC   AH
	 JNZ   VPUT_F
	 JMP   SHORT VPUT_D
VPUT	 ENDP

;********************************************************************
;
;  VSCORE - "SCORE" VERB HANDLER
;
;********************************************************************

VSCORE	 PROC
	 IF    R$PNTS
	 MOV   BL,POINTS
	 MOV   BH,0
	 LEA   SI,MSG24B
	 CALL  ASCLNO
	 CALL  SUPRES
	 ENDIF
	 DEC   SCORE
	 MOV   BX,SCORE
	 LEA   SI,MSG24A
	 CALL  ASCLNO
	 CALL  SUPRES
	 JMP   DMSG024
VSCORE	 ENDP

;********************************************************************
;
;  BADINP - PROCESS UNKNOWN INPUT
;
;********************************************************************

BADINP	 PROC
	 DEC   SCORE
	 LEA   BX,MSG4
	 CALL  DISPLY
	 LEA   BX,KEYBUF
	 CALL  DISPLY
	 MOV   AL,'"'
	 CALL  CHROUT
	 JMP   SHORT REPLY1
BADINP	 ENDP

;********************************************************************
;
;  REPLY  - ADVENTURE MAINLINE PROCESSOR
;
;********************************************************************

REPLY	 PROC
	 MOV   AL,POINTS
	 CMP   AL,MAXPNT1
	 LBEQ  FINI
	 TEST  NEWRM,0FFH
	 JZ    REPLY_D
	 MOV   FLIPSW,0
	 MOV   FLIPCT,0
	 MOV   FLP2SW,0
	 MOV   FLP2CT,0
	 MOV   RMMOVE,0
	 LEA   BX,ENTRTB
	 MOV   NEWRM,0
	 JMP   SHORT REPLY_E
REPLY_D:
	 LEA   BX,INRMTB
REPLY_E:
	 MOV   AL,[BX]
	 INC   BX
	 CMP   AL,0
	 JE    REPLY_G
	 CMP   AL,ROOM
	 JE    REPLY_F
	 ADD   BX,2
	 JMP   SHORT REPLY_E
REPLY_F:
	 CALL  WORD PTR [BX]
REPLY_G:
	 CALL  ECHMOV
REPLY1:
	 MOV   AX,STKSEG	  ;RESET THE STACK
	 cli
	 MOV   SS,AX
	 MOV   SP,OFFSET STKTOP
	 sti
	 ENABLE
	 LEA   BX,MSG0		;OK PROMPT
	 CALL  DISPLY
	 CALL  GETLIN
	 CALL  SCNKEY
	 INC   RMMOVE
	 INC   SCORE
	 LEA   BX,SPCRTN
REPLY_A:
	 MOV   AX,[BX]
	 ADD   BX,2
	 CMP   AX,0
	 JE    REPLY_C
	 CMP   AX,VERB_NOUN
	 JNE   REPLY_B
	 JMP   WORD PTR [BX]
REPLY_B:
	 ADD   BX,2
	 JMP   SHORT REPLY_A
REPLY_C:
	 MOV   AL,VERBNO
	 CMP   AL,0
	 LBEQ  BADINP
	 DEC   AL
	 SHL   AL,1
	 MOV   AH,0
	 LEA   BX,RTNTAB
	 ADD   BX,AX
	 JMP   WORD PTR [BX]
REPLY	 ENDP

;********************************************************************
;
;  VHELP  - GENERAL HELP VERB PROCESSOR
;
;********************************************************************

VHELP	 PROC
	 LEA   BX,GENHLP
	 MOV   AL,RANDOM
	 AND   AL,3
	 JZ    VHELP_B
VHELP_A:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JNZ   VHELP_A
	 DEC   AL
	 JNZ   VHELP_A
VHELP_B:
	 CALL  DISPLY
	 JMP   REPLY
VHELP	 ENDP

;********************************************************************
;
;  VSAVE  - SAVE GAME PROCESSOR
;
;********************************************************************

VSAVE	 PROC
	 DEC   SCORE
	 CALL  SAVGAM
	 JMP   REPLY
VSAVE	 ENDP

;********************************************************************
;
;  VLOAD  - LOAD GAME PROCESSOR
;
;********************************************************************

VLOAD	 PROC
	 DEC   SCORE
	 CALL  LODGAM
	 MOV   NOUNNO,0
	 JMP   VLOOK
VLOAD	 ENDP

;********************************************************************
;
;  DEAD1  - END OF GAME ROUTINES
;
;********************************************************************

DEAD1	 PROC
	 MOV   AL,DEADRM1
	 MOV   ROOM,AL
DEAD2:
	 CALL  CLSTXT
	 CALL  DRAWSC
	 CALL  DISPLY
	 JMP   SHORT ENDGAM
FINI:
	 LEA   BX,MSG27
;	 CALL  DISPLY
ENDGAM:
	 IF    R$PNTS
	 MOV   BL,POINTS
	 MOV   BH,0
	 LEA   SI,MSG25B
	 CALL  ASCLNO
	 CALL  SUPRES
	 ENDIF
	 MOV   BX,SCORE
	 LEA   SI,MSG25A
	 CALL  ASCLNO
	 CALL  SUPRES
	 LEA   BX,MSG25
	 CALL  DISPLY
	 CALL  GETLIN
	 MOV   AL,KEYBUF
	 AND   AL,11011111B	  ;CONVERT TO UPPER CASE
	 CMP   AL,'Y'
	 JNE   DEAD3
	 DISABLE
	 JMP   NEWGAM
DEAD3:
	 MOV   BX,OFFSET ENDMSG
	 CALL  DISPLY
DEAD4:
	 JMP   SHORT DEAD4
DEAD1	 ENDP

;********************************************************************
;
;  DSPMSG - DISPLAY MESSAGE ROUTINES
;
;********************************************************************

DSPMSG	 PROC
DMSG009: MOV   AL,009
	 DB    3DH
DMSG012: MOV   AL,012
	 DB    3DH
DMSG013: MOV   AL,013
	 DB    3DH
DMSG014: MOV   AL,014
	 DB    3DH
DMSG015: MOV   AL,015
	 DB    3DH
DMSG016: MOV   AL,016
	 DB    3DH
DMSG017: MOV   AL,017
	 DB    3DH
DMSG018: MOV   AL,018
	 DB    3DH
DMSG019: MOV   AL,019
	 DB    3DH
DMSG020: MOV   AL,020
	 DB    3DH
DMSG021: MOV   AL,021
	 DB    3DH
DMSG022: MOV   AL,022
	 DB    3DH
DMSG023: MOV   AL,023
	 DB    3DH
DMSG024: MOV   AL,024
	 DB    3DH
DMSG026: MOV   AL,026
	 DB    3DH
DMSG027: MOV   AL,027
	 DB    3DH
DMSG028: MOV   AL,028
	 DB    3DH
DMSG029: MOV   AL,029
	 DB    3DH
DMSG030: MOV   AL,030
	 DB    3DH
DMSG031: MOV   AL,031
	 DB    3DH
DMSG37	 EQU   $
DMSG037: MOV   AL,037
	 DB    3DH
DMSG040: MOV   AL,040
	 DB    3DH
DMSG043: MOV   AL,043
	 DB    3DH
DMSG057: MOV   AL,057
DMSGXX:
	 LEA   BX,MSG1
DMSGXX_A:
	 DEC   AL
	 JZ    DMSGXX_C
DMSGXX_B:
	 INC   BX
	 TEST  BYTE PTR [BX-1],0FFH
	 JNZ   DMSGXX_B
	 JMP   SHORT DMSGXX_A
DMSGXX_C:
	 CALL  DISPLY
	 JMP   REPLY
DSPMSG	 ENDP

;	 FILE: ADVCODE1.ASM
